package com.itheima.app.controller;

import com.itheima.app.makeFriendmanager.MakeFriendmanager;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@RestController
public class MakeFriendController {
    @Autowired
    private MakeFriendmanager makeFriendmanager;

    //今日佳人
    @GetMapping("/tanhua/todayBest")
    public ResponseEntity findTodayBest(){
        return makeFriendmanager.findTodayBest();
    }
    //推荐朋友
    @GetMapping("/tanhua/recommendation")
    public ResponseEntity findRecommendUserList(
            @RequestParam(value = "page", defaultValue = "1") Integer pageNum,
            @RequestParam(value = "pagesize", defaultValue = "10") Integer pageSize
    ){
        return makeFriendmanager.findRecommendUserList(pageNum,pageSize);
    }
    // 用户详情封面
    @GetMapping("/tanhua/{jiarenId}/personalInfo")
    public ResponseEntity findRecommendDetailHead(@PathVariable Long jiarenId) {
        return makeFriendmanager.findRecommendDetailHead(jiarenId);
    }
    // 是否喜欢他（她）
    @GetMapping("/users/{likeUserId}/alreadyLove")
    public ResponseEntity findAlreadyLove(@PathVariable Long likeUserId){
        return ResponseEntity.ok(false);
    }
    // 历史访客
    @GetMapping("/movements/visitors")
    public ResponseEntity findVisitors() {
        return makeFriendmanager.findVisitors();
    }
    //上传地理位置
    @PostMapping("/baidu/location")
    public  void uploadLocation(@RequestBody Map<String, String> param){
        String longitude = param.get("longitude");//经度
        String latitude = param.get("latitude");//维度
        String addrStr = param.get("addrStr");//位置描述
         makeFriendmanager.uploadLocation(longitude,latitude,addrStr);
    }
    //搜附近
    @GetMapping("/tanhua/search")
    public ResponseEntity searchNearUser(String gender, Long distance){
        return makeFriendmanager.searchNearUser(gender,distance);
    }
    //查看陌生人问题
    @GetMapping("/tanhua/strangerQuestions")
    public ResponseEntity findByQuestions(@RequestParam("userId") Long jiarenId){
        return makeFriendmanager.findByQuestions(jiarenId);
    }
}
